<template>
  <div class="search">
    <a-drawer :visible="modalVisible" :title="modalTitle" width="880" @close="handleClose">

      <f-form ref="authForm" :action="api.company.setAuditState" :form-key="this.formItem.companyId">
        <f-form-item label="店铺Logo" name="shopLogo" type="upload" :value="formItem.shopLogo" :file-max="1"/>
        <f-form-item label="店铺名称" name="shopName" :value="formItem.shopName"/>
        <f-form-item label="联系人" name="linkMan" :value="formItem.linkMan"/>
        <f-form-item label="联系电话" name="linkTel" :value="formItem.linkTel"/>
        <f-form-item label="营业范围" name="businessScope" type="textarea" :value="formItem.businessScope"/>
        <f-form-item label="店铺简介" name="shopDesc" type="editor" :value="formItem"/>
        <f-form-item label="是否通过" name="shopState" :required="true" type="radio" data-type="number" :data="api.shop.auditState" :value="shopState"/>
      </f-form>
      <div class="drawer-footer">
        <a-button type="default" @click="handleClose">取消</a-button>&nbsp;
        <a-button type="primary" @click="handleSubmit" :loading="saving">保存</a-button>
      </div>
    </a-drawer>
  </div>
</template>

<script>

  export default {
    name: 'companyAudit',
    props: {},
    data () {
      return {
        saving: false,
        shopState: 2,
        modalVisible: false,
        formItem: this.getFormItem()
      }
    },
    computed: {
      modalTitle: function () {
        return '店铺审核-' + this.formItem.shopName
      }
    },
    methods: {
      getFormItem () {
        return {}
      },
      handleShow (data) {
        if (data && data.shopId) {
          this.modalVisible = true
          this.$nextTick(() => {
            this.$refs.authForm.resetFields()
          })
          this.formItem = data

        }
      },
      handleClose () {
        this.modalVisible = false
      },
      handleSubmit () {
        this.$refs.authForm.submit({ shopState: this.shopState, ...this.formItem })
      }
    },
    created () {
      //监听modal关闭事件
      this.$bus.on('closeModal', (name) => {
        this.modalVisible = false
      })
    },
    components: {}
  }
</script>

<style scoped lang="less" rel="stylesheet/less">

</style>
